package vectortile.value;

import com.google.protobuf.*;
import vectortile.model.VectorTile;

/**
 * @Author jlj
 * @Date 2020/12/28 11:52
 * @Description Variant type encoding The use of values is described in section 4.1 of the specification
 * Protobuf type {@code vector_tile.Tile.Value}
 * @Modified
 */
public final class Value extends GeneratedMessageV3.ExtendableMessage<Value>
        implements ValueOrBuilder {
    private static final long serialVersionUID = 0L;

    // Use Value.newBuilder() to construct.
    private Value(GeneratedMessageV3.ExtendableBuilder<Value, ?> builder) {
        super(builder);
    }

    private Value() {
        stringValue_ = "";
        floatValue_ = 0F;
        doubleValue_ = 0D;
        intValue_ = 0L;
        uintValue_ = 0L;
        sintValue_ = 0L;
        boolValue_ = false;
    }

    @java.lang.Override
    public final UnknownFieldSet getUnknownFields() {
        return this.unknownFields;
    }

    private Value(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
            throws InvalidProtocolBufferException {
        this();
        if (extensionRegistry == null) {
            throw new java.lang.NullPointerException();
        }
        int mutable_bitField0_ = 0;
        UnknownFieldSet.Builder unknownFields =
                UnknownFieldSet.newBuilder();
        try {
            boolean done = false;
            while (!done) {
                int tag = input.readTag();
                switch (tag) {
                    case 0:
                        done = true;
                        break;
                    case 10: {
                        ByteString bs = input.readBytes();
                        bitField0_ |= 0x00000001;
                        stringValue_ = bs;
                        break;
                    }
                    case 21: {
                        bitField0_ |= 0x00000002;
                        floatValue_ = input.readFloat();
                        break;
                    }
                    case 25: {
                        bitField0_ |= 0x00000004;
                        doubleValue_ = input.readDouble();
                        break;
                    }
                    case 32: {
                        bitField0_ |= 0x00000008;
                        intValue_ = input.readInt64();
                        break;
                    }
                    case 40: {
                        bitField0_ |= 0x00000010;
                        uintValue_ = input.readUInt64();
                        break;
                    }
                    case 48: {
                        bitField0_ |= 0x00000020;
                        sintValue_ = input.readSInt64();
                        break;
                    }
                    case 56: {
                        bitField0_ |= 0x00000040;
                        boolValue_ = input.readBool();
                        break;
                    }
                    default: {
                        if (!parseUnknownField(
                                input, unknownFields, extensionRegistry, tag)) {
                            done = true;
                        }
                        break;
                    }
                }
            }
        } catch (InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(this);
        } catch (java.io.IOException e) {
            throw new InvalidProtocolBufferException(e).setUnfinishedMessage(this);
        } finally {
            this.unknownFields = unknownFields.build();
            makeExtensionsImmutable();
        }
    }

    public static final Descriptors.Descriptor
    getDescriptor() {
        return VectorTile.internal_static_vector_tile_Tile_Value_descriptor;
    }

    @java.lang.Override
    protected GeneratedMessageV3.FieldAccessorTable
    internalGetFieldAccessorTable() {
        return VectorTile.internal_static_vector_tile_Tile_Value_fieldAccessorTable
                .ensureFieldAccessorsInitialized(Value.class, Value.Builder.class);
    }

    private int bitField0_;
    public static final int STRING_VALUE_FIELD_NUMBER = 1;
    private volatile java.lang.Object stringValue_;

    /**
     * <pre>
     * Exactly one of these values must be present in a valid message
     * </pre>
     *
     * <code>optional string string_value = 1;</code>
     */
    public boolean hasStringValue() {
        return ((bitField0_ & 0x00000001) == 0x00000001);
    }

    /**
     * <pre>
     * Exactly one of these values must be present in a valid message
     * </pre>
     *
     * <code>optional string string_value = 1;</code>
     */
    public java.lang.String getStringValue() {
        java.lang.Object ref = stringValue_;
        if (ref instanceof java.lang.String) {
            return (java.lang.String) ref;
        } else {
            ByteString bs = (ByteString) ref;
            java.lang.String s = bs.toStringUtf8();
            if (bs.isValidUtf8()) {
                stringValue_ = s;
            }
            return s;
        }
    }

    /**
     * <pre>
     * Exactly one of these values must be present in a valid message
     * </pre>
     *
     * <code>optional string string_value = 1;</code>
     */
    public ByteString getStringValueBytes() {
        java.lang.Object ref = stringValue_;
        if (ref instanceof java.lang.String) {
            ByteString b = ByteString.copyFromUtf8((java.lang.String) ref);
            stringValue_ = b;
            return b;
        } else {
            return (ByteString) ref;
        }
    }

    public static final int FLOAT_VALUE_FIELD_NUMBER = 2;
    private float floatValue_;

    /**
     * <code>optional float float_value = 2;</code>
     */
    public boolean hasFloatValue() {
        return ((bitField0_ & 0x00000002) == 0x00000002);
    }

    /**
     * <code>optional float float_value = 2;</code>
     */
    public float getFloatValue() {
        return floatValue_;
    }

    public static final int DOUBLE_VALUE_FIELD_NUMBER = 3;
    private double doubleValue_;

    /**
     * <code>optional double double_value = 3;</code>
     */
    public boolean hasDoubleValue() {
        return ((bitField0_ & 0x00000004) == 0x00000004);
    }

    /**
     * <code>optional double double_value = 3;</code>
     */
    public double getDoubleValue() {
        return doubleValue_;
    }

    public static final int INT_VALUE_FIELD_NUMBER = 4;
    private long intValue_;

    /**
     * <code>optional int64 int_value = 4;</code>
     */
    public boolean hasIntValue() {
        return ((bitField0_ & 0x00000008) == 0x00000008);
    }

    /**
     * <code>optional int64 int_value = 4;</code>
     */
    public long getIntValue() {
        return intValue_;
    }

    public static final int UINT_VALUE_FIELD_NUMBER = 5;
    private long uintValue_;

    /**
     * <code>optional uint64 uint_value = 5;</code>
     */
    public boolean hasUintValue() {
        return ((bitField0_ & 0x00000010) == 0x00000010);
    }

    /**
     * <code>optional uint64 uint_value = 5;</code>
     */
    public long getUintValue() {
        return uintValue_;
    }

    public static final int SINT_VALUE_FIELD_NUMBER = 6;
    private long sintValue_;

    /**
     * <code>optional sint64 sint_value = 6;</code>
     */
    public boolean hasSintValue() {
        return ((bitField0_ & 0x00000020) == 0x00000020);
    }

    /**
     * <code>optional sint64 sint_value = 6;</code>
     */
    public long getSintValue() {
        return sintValue_;
    }

    public static final int BOOL_VALUE_FIELD_NUMBER = 7;
    private boolean boolValue_;

    /**
     * <code>optional bool bool_value = 7;</code>
     */
    public boolean hasBoolValue() {
        return ((bitField0_ & 0x00000040) == 0x00000040);
    }

    /**
     * <code>optional bool bool_value = 7;</code>
     */
    public boolean getBoolValue() {
        return boolValue_;
    }

    private byte memoizedIsInitialized = -1;

    @java.lang.Override
    public final boolean isInitialized() {
        byte isInitialized = memoizedIsInitialized;
        if (isInitialized == 1) return true;
        if (isInitialized == 0) return false;

        if (!extensionsAreInitialized()) {
            memoizedIsInitialized = 0;
            return false;
        }
        memoizedIsInitialized = 1;
        return true;
    }

    @java.lang.Override
    public void writeTo(CodedOutputStream output) throws java.io.IOException {
        GeneratedMessageV3.ExtendableMessage<Value>.ExtensionWriter extensionWriter = newExtensionWriter();
        if (((bitField0_ & 0x00000001) == 0x00000001)) {
            GeneratedMessageV3.writeString(output, 1, stringValue_);
        }
        if (((bitField0_ & 0x00000002) == 0x00000002)) {
            output.writeFloat(2, floatValue_);
        }
        if (((bitField0_ & 0x00000004) == 0x00000004)) {
            output.writeDouble(3, doubleValue_);
        }
        if (((bitField0_ & 0x00000008) == 0x00000008)) {
            output.writeInt64(4, intValue_);
        }
        if (((bitField0_ & 0x00000010) == 0x00000010)) {
            output.writeUInt64(5, uintValue_);
        }
        if (((bitField0_ & 0x00000020) == 0x00000020)) {
            output.writeSInt64(6, sintValue_);
        }
        if (((bitField0_ & 0x00000040) == 0x00000040)) {
            output.writeBool(7, boolValue_);
        }
        extensionWriter.writeUntil(536870912, output);
        unknownFields.writeTo(output);
    }

    @java.lang.Override
    public int getSerializedSize() {
        int size = memoizedSize;
        if (size != -1) return size;

        size = 0;
        if (((bitField0_ & 0x00000001) == 0x00000001)) {
            size += GeneratedMessageV3.computeStringSize(1, stringValue_);
        }
        if (((bitField0_ & 0x00000002) == 0x00000002)) {
            size += CodedOutputStream
                    .computeFloatSize(2, floatValue_);
        }
        if (((bitField0_ & 0x00000004) == 0x00000004)) {
            size += CodedOutputStream
                    .computeDoubleSize(3, doubleValue_);
        }
        if (((bitField0_ & 0x00000008) == 0x00000008)) {
            size += CodedOutputStream
                    .computeInt64Size(4, intValue_);
        }
        if (((bitField0_ & 0x00000010) == 0x00000010)) {
            size += CodedOutputStream
                    .computeUInt64Size(5, uintValue_);
        }
        if (((bitField0_ & 0x00000020) == 0x00000020)) {
            size += CodedOutputStream
                    .computeSInt64Size(6, sintValue_);
        }
        if (((bitField0_ & 0x00000040) == 0x00000040)) {
            size += CodedOutputStream
                    .computeBoolSize(7, boolValue_);
        }
        size += extensionsSerializedSize();
        size += unknownFields.getSerializedSize();
        memoizedSize = size;
        return size;
    }

    @java.lang.Override
    public boolean equals(final java.lang.Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof Value)) {
            return super.equals(obj);
        }
        Value other = (Value) obj;

        boolean result = true;
        result = result && (hasStringValue() == other.hasStringValue());
        if (hasStringValue()) {
            result = result && getStringValue().equals(other.getStringValue());
        }
        result = result && (hasFloatValue() == other.hasFloatValue());
        if (hasFloatValue()) {
            result = result && (java.lang.Float.floatToIntBits(getFloatValue()) ==
                    java.lang.Float.floatToIntBits(other.getFloatValue()));
        }
        result = result && (hasDoubleValue() == other.hasDoubleValue());
        if (hasDoubleValue()) {
            result = result && (java.lang.Double.doubleToLongBits(getDoubleValue())
                    == java.lang.Double.doubleToLongBits(other.getDoubleValue()));
        }
        result = result && (hasIntValue() == other.hasIntValue());
        if (hasIntValue()) {
            result = result && (getIntValue() == other.getIntValue());
        }
        result = result && (hasUintValue() == other.hasUintValue());
        if (hasUintValue()) {
            result = result && (getUintValue() == other.getUintValue());
        }
        result = result && (hasSintValue() == other.hasSintValue());
        if (hasSintValue()) {
            result = result && (getSintValue() == other.getSintValue());
        }
        result = result && (hasBoolValue() == other.hasBoolValue());
        if (hasBoolValue()) {
            result = result && (getBoolValue() == other.getBoolValue());
        }
        result = result && unknownFields.equals(other.unknownFields);
        result = result && getExtensionFields().equals(other.getExtensionFields());
        return result;
    }

    @java.lang.Override
    public int hashCode() {
        if (memoizedHashCode != 0) {
            return memoizedHashCode;
        }
        int hash = 41;
        hash = (19 * hash) + getDescriptor().hashCode();
        if (hasStringValue()) {
            hash = (37 * hash) + STRING_VALUE_FIELD_NUMBER;
            hash = (53 * hash) + getStringValue().hashCode();
        }
        if (hasFloatValue()) {
            hash = (37 * hash) + FLOAT_VALUE_FIELD_NUMBER;
            hash = (53 * hash) + java.lang.Float.floatToIntBits(getFloatValue());
        }
        if (hasDoubleValue()) {
            hash = (37 * hash) + DOUBLE_VALUE_FIELD_NUMBER;
            hash = (53 * hash) + Internal.hashLong(java.lang.Double.doubleToLongBits(getDoubleValue()));
        }
        if (hasIntValue()) {
            hash = (37 * hash) + INT_VALUE_FIELD_NUMBER;
            hash = (53 * hash) + Internal.hashLong(getIntValue());
        }
        if (hasUintValue()) {
            hash = (37 * hash) + UINT_VALUE_FIELD_NUMBER;
            hash = (53 * hash) + Internal.hashLong(getUintValue());
        }
        if (hasSintValue()) {
            hash = (37 * hash) + SINT_VALUE_FIELD_NUMBER;
            hash = (53 * hash) + Internal.hashLong(getSintValue());
        }
        if (hasBoolValue()) {
            hash = (37 * hash) + BOOL_VALUE_FIELD_NUMBER;
            hash = (53 * hash) + Internal.hashBoolean(getBoolValue());
        }
        hash = hashFields(hash, getExtensionFields());
        hash = (29 * hash) + unknownFields.hashCode();
        memoizedHashCode = hash;
        return hash;
    }

    public static Value parseFrom(java.nio.ByteBuffer data)
            throws InvalidProtocolBufferException {
        return PARSER.parseFrom(data);
    }

    public static Value parseFrom(java.nio.ByteBuffer data, ExtensionRegistryLite extensionRegistry)
            throws InvalidProtocolBufferException {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static Value parseFrom(ByteString data)
            throws InvalidProtocolBufferException {
        return PARSER.parseFrom(data);
    }

    public static Value parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
            throws InvalidProtocolBufferException {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static Value parseFrom(byte[] data) throws InvalidProtocolBufferException {
        return PARSER.parseFrom(data);
    }

    public static Value parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
            throws InvalidProtocolBufferException {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static Value parseFrom(java.io.InputStream input) throws java.io.IOException {
        return GeneratedMessageV3.parseWithIOException(PARSER, input);
    }

    public static Value parseFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException {
        return GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry);
    }

    public static Value parseDelimitedFrom(java.io.InputStream input)
            throws java.io.IOException {
        return GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
    }

    public static Value parseDelimitedFrom(java.io.InputStream input, ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException {
        return GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
    }

    public static Value parseFrom(CodedInputStream input)
            throws java.io.IOException {
        return GeneratedMessageV3.parseWithIOException(PARSER, input);
    }

    public static Value parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException {
        return GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry);
    }

    @java.lang.Override
    public Builder newBuilderForType() {
        return newBuilder();
    }

    public static Builder newBuilder() {
        return DEFAULT_INSTANCE.toBuilder();
    }

    public static Builder newBuilder(Value prototype) {
        return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
    }

    @java.lang.Override
    public Builder toBuilder() {
        return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
    }

    @java.lang.Override
    protected Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent) {
        Builder builder = new Builder(parent);
        return builder;
    }

    /**
     * <pre>
     * Variant type encoding
     * The use of values is described in section 4.1 of the specification
     * </pre>
     * <p>
     * Protobuf type {@code vector_tile.Tile.Value}
     */
    public static final class Builder extends GeneratedMessageV3.ExtendableBuilder<Value, Builder>
            implements ValueOrBuilder {
        public static final Descriptors.Descriptor getDescriptor() {
            return VectorTile.internal_static_vector_tile_Tile_Value_descriptor;
        }

        @java.lang.Override
        protected GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
            return VectorTile.internal_static_vector_tile_Tile_Value_fieldAccessorTable
                    .ensureFieldAccessorsInitialized(Value.class, Builder.class);
        }

        // Construct using vector_tile.VectorTile.Tile.Value.newBuilder()
        private Builder() {
            maybeForceBuilderInitialization();
        }

        private Builder(
                GeneratedMessageV3.BuilderParent parent) {
            super(parent);
            maybeForceBuilderInitialization();
        }

        private void maybeForceBuilderInitialization() {
            if (GeneratedMessageV3
                    .alwaysUseFieldBuilders) {
            }
        }

        @java.lang.Override
        public Builder clear() {
            super.clear();
            stringValue_ = "";
            bitField0_ = (bitField0_ & ~0x00000001);
            floatValue_ = 0F;
            bitField0_ = (bitField0_ & ~0x00000002);
            doubleValue_ = 0D;
            bitField0_ = (bitField0_ & ~0x00000004);
            intValue_ = 0L;
            bitField0_ = (bitField0_ & ~0x00000008);
            uintValue_ = 0L;
            bitField0_ = (bitField0_ & ~0x00000010);
            sintValue_ = 0L;
            bitField0_ = (bitField0_ & ~0x00000020);
            boolValue_ = false;
            bitField0_ = (bitField0_ & ~0x00000040);
            return this;
        }

        @java.lang.Override
        public Descriptors.Descriptor
        getDescriptorForType() {
            return VectorTile.internal_static_vector_tile_Tile_Value_descriptor;
        }

        @java.lang.Override
        public Value getDefaultInstanceForType() {
            return Value.getDefaultInstance();
        }

        @java.lang.Override
        public Value build() {
            Value result = buildPartial();
            if (!result.isInitialized()) {
                throw newUninitializedMessageException(result);
            }
            return result;
        }

        @java.lang.Override
        public Value buildPartial() {
            Value result = new Value(this);
            int from_bitField0_ = bitField0_;
            int to_bitField0_ = 0;
            if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
                to_bitField0_ |= 0x00000001;
            }
            result.stringValue_ = stringValue_;
            if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
                to_bitField0_ |= 0x00000002;
            }
            result.floatValue_ = floatValue_;
            if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
                to_bitField0_ |= 0x00000004;
            }
            result.doubleValue_ = doubleValue_;
            if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
                to_bitField0_ |= 0x00000008;
            }
            result.intValue_ = intValue_;
            if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
                to_bitField0_ |= 0x00000010;
            }
            result.uintValue_ = uintValue_;
            if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
                to_bitField0_ |= 0x00000020;
            }
            result.sintValue_ = sintValue_;
            if (((from_bitField0_ & 0x00000040) == 0x00000040)) {
                to_bitField0_ |= 0x00000040;
            }
            result.boolValue_ = boolValue_;
            result.bitField0_ = to_bitField0_;
            onBuilt();
            return result;
        }

        @java.lang.Override
        public Builder clone() {
            return (Builder) super.clone();
        }

        @java.lang.Override
        public Builder setField(Descriptors.FieldDescriptor field,
                                java.lang.Object value) {
            return (Builder) super.setField(field, value);
        }

        @java.lang.Override
        public Builder clearField(Descriptors.FieldDescriptor field) {
            return (Builder) super.clearField(field);
        }

        @java.lang.Override
        public Builder clearOneof(Descriptors.OneofDescriptor oneof) {
            return (Builder) super.clearOneof(oneof);
        }

        @java.lang.Override
        public Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
            return (Builder) super.setRepeatedField(field, index, value);
        }

        @java.lang.Override
        public Builder addRepeatedField(Descriptors.FieldDescriptor field, java.lang.Object value) {
            return (Builder) super.addRepeatedField(field, value);
        }

        @java.lang.Override
        public <Type> Builder setExtension(GeneratedMessage.GeneratedExtension<Value, Type> extension, Type value) {
            return (Builder) super.setExtension(extension, value);
        }

        @java.lang.Override
        public <Type> Builder setExtension(GeneratedMessage.GeneratedExtension<Value, java.util.List<Type>> extension,
                                           int index, Type value) {
            return (Builder) super.setExtension(extension, index, value);
        }

        @java.lang.Override
        public <Type> Builder addExtension(GeneratedMessage.GeneratedExtension<Value, java.util.List<Type>> extension,
                                           Type value) {
            return (Builder) super.addExtension(extension, value);
        }

        @java.lang.Override
        public <Type> Builder clearExtension(GeneratedMessage.GeneratedExtension<Value, ?> extension) {
            return (Builder) super.clearExtension(extension);
        }

        @java.lang.Override
        public Builder mergeFrom(Message other) {
            if (other instanceof Value) {
                return mergeFrom((Value) other);
            } else {
                super.mergeFrom(other);
                return this;
            }
        }

        public Builder mergeFrom(Value other) {
            if (other == Value.getDefaultInstance()) return this;
            if (other.hasStringValue()) {
                bitField0_ |= 0x00000001;
                stringValue_ = other.stringValue_;
                onChanged();
            }
            if (other.hasFloatValue()) {
                setFloatValue(other.getFloatValue());
            }
            if (other.hasDoubleValue()) {
                setDoubleValue(other.getDoubleValue());
            }
            if (other.hasIntValue()) {
                setIntValue(other.getIntValue());
            }
            if (other.hasUintValue()) {
                setUintValue(other.getUintValue());
            }
            if (other.hasSintValue()) {
                setSintValue(other.getSintValue());
            }
            if (other.hasBoolValue()) {
                setBoolValue(other.getBoolValue());
            }
            this.mergeExtensionFields(other);
            this.mergeUnknownFields(other.unknownFields);
            onChanged();
            return this;
        }

        @java.lang.Override
        public final boolean isInitialized() {
            if (!extensionsAreInitialized()) {
                return false;
            }
            return true;
        }

        @java.lang.Override
        public Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
                throws java.io.IOException {
            Value parsedMessage = null;
            try {
                parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
            } catch (InvalidProtocolBufferException e) {
                parsedMessage = (Value) e.getUnfinishedMessage();
                throw e.unwrapIOException();
            } finally {
                if (parsedMessage != null) {
                    mergeFrom(parsedMessage);
                }
            }
            return this;
        }

        private int bitField0_;

        private java.lang.Object stringValue_ = "";

        /**
         * <pre>
         * Exactly one of these values must be present in a valid message
         * </pre>
         *
         * <code>optional string string_value = 1;</code>
         */
        public boolean hasStringValue() {
            return ((bitField0_ & 0x00000001) == 0x00000001);
        }

        /**
         * <pre>
         * Exactly one of these values must be present in a valid message
         * </pre>
         *
         * <code>optional string string_value = 1;</code>
         */
        public java.lang.String getStringValue() {
            java.lang.Object ref = stringValue_;
            if (!(ref instanceof java.lang.String)) {
                ByteString bs = (ByteString) ref;
                java.lang.String s = bs.toStringUtf8();
                if (bs.isValidUtf8()) {
                    stringValue_ = s;
                }
                return s;
            } else {
                return (java.lang.String) ref;
            }
        }

        /**
         * <pre>
         * Exactly one of these values must be present in a valid message
         * </pre>
         *
         * <code>optional string string_value = 1;</code>
         */
        public ByteString
        getStringValueBytes() {
            java.lang.Object ref = stringValue_;
            if (ref instanceof String) {
                ByteString b = ByteString.copyFromUtf8((java.lang.String) ref);
                stringValue_ = b;
                return b;
            } else {
                return (ByteString) ref;
            }
        }

        /**
         * <pre>
         * Exactly one of these values must be present in a valid message
         * </pre>
         *
         * <code>optional string string_value = 1;</code>
         */
        public Builder setStringValue(java.lang.String value) {
            if (value == null) {
                throw new NullPointerException();
            }
            bitField0_ |= 0x00000001;
            stringValue_ = value;
            onChanged();
            return this;
        }

        /**
         * <pre>
         * Exactly one of these values must be present in a valid message
         * </pre>
         *
         * <code>optional string string_value = 1;</code>
         */
        public Builder clearStringValue() {
            bitField0_ = (bitField0_ & ~0x00000001);
            stringValue_ = getDefaultInstance().getStringValue();
            onChanged();
            return this;
        }

        /**
         * <pre>
         * Exactly one of these values must be present in a valid message
         * </pre>
         *
         * <code>optional string string_value = 1;</code>
         */
        public Builder setStringValueBytes(ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }
            bitField0_ |= 0x00000001;
            stringValue_ = value;
            onChanged();
            return this;
        }

        private float floatValue_;

        /**
         * <code>optional float float_value = 2;</code>
         */
        public boolean hasFloatValue() {
            return ((bitField0_ & 0x00000002) == 0x00000002);
        }

        /**
         * <code>optional float float_value = 2;</code>
         */
        public float getFloatValue() {
            return floatValue_;
        }

        /**
         * <code>optional float float_value = 2;</code>
         */
        public Builder setFloatValue(float value) {
            bitField0_ |= 0x00000002;
            floatValue_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>optional float float_value = 2;</code>
         */
        public Builder clearFloatValue() {
            bitField0_ = (bitField0_ & ~0x00000002);
            floatValue_ = 0F;
            onChanged();
            return this;
        }

        private double doubleValue_;

        /**
         * <code>optional double double_value = 3;</code>
         */
        public boolean hasDoubleValue() {
            return ((bitField0_ & 0x00000004) == 0x00000004);
        }

        /**
         * <code>optional double double_value = 3;</code>
         */
        public double getDoubleValue() {
            return doubleValue_;
        }

        /**
         * <code>optional double double_value = 3;</code>
         */
        public Builder setDoubleValue(double value) {
            bitField0_ |= 0x00000004;
            doubleValue_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>optional double double_value = 3;</code>
         */
        public Builder clearDoubleValue() {
            bitField0_ = (bitField0_ & ~0x00000004);
            doubleValue_ = 0D;
            onChanged();
            return this;
        }

        private long intValue_;

        /**
         * <code>optional int64 int_value = 4;</code>
         */
        public boolean hasIntValue() {
            return ((bitField0_ & 0x00000008) == 0x00000008);
        }

        /**
         * <code>optional int64 int_value = 4;</code>
         */
        public long getIntValue() {
            return intValue_;
        }

        /**
         * <code>optional int64 int_value = 4;</code>
         */
        public Builder setIntValue(long value) {
            bitField0_ |= 0x00000008;
            intValue_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>optional int64 int_value = 4;</code>
         */
        public Builder clearIntValue() {
            bitField0_ = (bitField0_ & ~0x00000008);
            intValue_ = 0L;
            onChanged();
            return this;
        }

        private long uintValue_;

        /**
         * <code>optional uint64 uint_value = 5;</code>
         */
        public boolean hasUintValue() {
            return ((bitField0_ & 0x00000010) == 0x00000010);
        }

        /**
         * <code>optional uint64 uint_value = 5;</code>
         */
        public long getUintValue() {
            return uintValue_;
        }

        /**
         * <code>optional uint64 uint_value = 5;</code>
         */
        public Builder setUintValue(long value) {
            bitField0_ |= 0x00000010;
            uintValue_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>optional uint64 uint_value = 5;</code>
         */
        public Builder clearUintValue() {
            bitField0_ = (bitField0_ & ~0x00000010);
            uintValue_ = 0L;
            onChanged();
            return this;
        }

        private long sintValue_;

        /**
         * <code>optional sint64 sint_value = 6;</code>
         */
        public boolean hasSintValue() {
            return ((bitField0_ & 0x00000020) == 0x00000020);
        }

        /**
         * <code>optional sint64 sint_value = 6;</code>
         */
        public long getSintValue() {
            return sintValue_;
        }

        /**
         * <code>optional sint64 sint_value = 6;</code>
         */
        public Builder setSintValue(long value) {
            bitField0_ |= 0x00000020;
            sintValue_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>optional sint64 sint_value = 6;</code>
         */
        public Builder clearSintValue() {
            bitField0_ = (bitField0_ & ~0x00000020);
            sintValue_ = 0L;
            onChanged();
            return this;
        }

        private boolean boolValue_;

        /**
         * <code>optional bool bool_value = 7;</code>
         */
        public boolean hasBoolValue() {
            return ((bitField0_ & 0x00000040) == 0x00000040);
        }

        /**
         * <code>optional bool bool_value = 7;</code>
         */
        public boolean getBoolValue() {
            return boolValue_;
        }

        /**
         * <code>optional bool bool_value = 7;</code>
         */
        public Builder setBoolValue(boolean value) {
            bitField0_ |= 0x00000040;
            boolValue_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>optional bool bool_value = 7;</code>
         */
        public Builder clearBoolValue() {
            bitField0_ = (bitField0_ & ~0x00000040);
            boolValue_ = false;
            onChanged();
            return this;
        }

        @java.lang.Override
        public final Builder setUnknownFields(final UnknownFieldSet unknownFields) {
            return super.setUnknownFields(unknownFields);
        }

        @java.lang.Override
        public final Builder mergeUnknownFields(final UnknownFieldSet unknownFields) {
            return super.mergeUnknownFields(unknownFields);
        }
    }

    // @@protoc_insertion_point(class_scope:Value)
    private static final Value DEFAULT_INSTANCE;

    static {
        DEFAULT_INSTANCE = new Value();
    }

    public static Value getDefaultInstance() {
        return DEFAULT_INSTANCE;
    }

    @java.lang.Deprecated
    public static final Parser<Value> PARSER = new AbstractParser<Value>() {
        @java.lang.Override
        public Value parsePartialFrom(CodedInputStream input,                                      ExtensionRegistryLite extensionRegistry)
                throws InvalidProtocolBufferException {
            return new Value(input, extensionRegistry);
        }
    };

    public static Parser<Value> parser() {
        return PARSER;
    }

    @java.lang.Override
    public Parser<Value> getParserForType() {
        return PARSER;
    }

    @java.lang.Override
    public Value getDefaultInstanceForType() {
        return DEFAULT_INSTANCE;
    }

}